import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules */

/** note: sub-menu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']    will control the page roles (you can set multiple roles)
    title: 'title'               the name show in sub-menu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if true, the page will no be cached(default is false)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
    affix: true                  if true, the tag will affix in the tags-view
  }
**/
export const constantRouterMap = [{
  path: '/login',
  component: () => import('@/views/login/index'),
  hidden: true
},
{
  path: '',
  component: Layout,
  redirect: 'home',
  children: [{
    path: 'home',
    component: () => import('@/views/home/index'),
    name: 'home',
    meta: {
      title: '首页',
      icon: 'dashboard',
      noCache: true
    }
  }]
},
{
  path: '/404',
  component: () => import('@/views/errorPage/404'),
  hidden: true
},
{
  path: '/401',
  component: () => import('@/views/errorPage/401'),
  hidden: true
}
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // Banner管理
  {
    path: '/banner',
    name: '/banner',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '轮播图管理',
      icon: 'banner'
    },
    children: [{
      path: 'bannerclass',
      component: () => import('@/views/banner/bannerclass'),
      name: '/v1/bannerclass',
      meta: {
        title: '轮播图列表'
      }
    }]
  },
  // 系统管理
  {
    path: '/system',
    name: '/system',
    redirect: 'parameter',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '系统管理',
      icon: 'xitong'
    },
    children: [{
      path: 'parameter',
      component: () => import('@/views/system/parameter'),
      name: '/v1/parameter',
      meta: {
        title: '系统参数管理'
      }
    }, {

      path: 'enterprise',
      component: () => import('@/views/system/enterprise'),
      name: '/v1/enterprise',
      meta: {
        title: '企业信息'
      }
    },
    {
      path: 'organization',
      component: () => import('@/views/system/organization'),
      name: '/v1/organization',
      meta: {
        title: '组织机构管理'
      }
    },
      /* {
        path: 'OrganizationList',
        component: () => import('@/views/system/OrganizationList'),
        name: '/v1/OrganizationList',
        meta: {
          title: '组织机构'
        }
      },*/

    {
      path: 'user',
      component: () => import('@/views/system/user'),
      name: '/v1/user',
      meta: {
        title: '系统用户管理'
      }
    },
    {
      path: 'role',
      component: () => import('@/views/system/role'),
      name: '/v1/role',
      meta: {
        title: '系统角色管理'
      }
    },
    {
      path: 'permissions',
      component: () => import('@/views/system/permissions'),
      name: '/v1/permissions',
      meta: {
        title: '系统菜单管理'
      }
    },
    {
      path: 'region',
      component: () => import('@/views/system/region'),
      name: '/v1/region',
      meta: {
        title: '系统地区管理'
      }
    },
    {
      path: 'timedtask',
      component: () => import('@/views/system/timedtask'),
      name: '/v1/timedtask',
      meta: {
        title: '系统定时任务管理'
      }
    }
    ]
  },
  // 平台商品管理
  {
    path: '/commodity',
    name: '/commodity',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '平台商品管理',
      icon: 'shangpin'
    },
    children: [{
      path: 'category',
      component: () => import('@/views/commodity/category'),
      name: '/v1/category',
      meta: {
        title: '类别列表'
      }
    },
    {
      path: 'commodity',
      component: () => import('@/views/commodity/commodity'),
      name: '/v1/commodity',
      meta: {
        title: '商品列表'
      }
    }
    ]
  },
  // 平台订单管理
  {
    path: '/activitynotice',
    name: '/v1/order',
    component: Layout,
    alwaysShow: true,
    redirect: 'activitynotice',
    meta: {
      title: '平台订单管理',
      icon: 'announcement'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/orderList',
      meta: {
        title: '平台订单列表'
      }
    }]
  },
  // 平台商品SKU管理
  {
    path: '/sku',
    name: '/sku',
    component: Layout,
    alwaysShow: true,
    redirect: 'sku',
    meta: {
      title: '平台商品SKU管理',
      icon: ''
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/skuList',
      meta: {
        title: 'SKU列表'
      }
    }]
  },

  // 门店管理
  {
    path: '/shop',
    name: '/shop',
    component: Layout,
    alwaysShow: true,
    redirect: 'shop',
    meta: {
      title: '门店管理',
      icon: 'shangjia'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/venue/venue'),
      name: '/v1/shopList',
      meta: {
        title: '门店列表'
      }
    }]
  },


  // 门店会员管理
  {
    path: '/shopMember',
    name: '/shopMember',
    component: Layout,
    alwaysShow: true,
    redirect: 'shop',
    meta: {
      title: '门店会员管理',
      icon: 'huiyuan'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/shopMemberList',
      meta: {
        title: '门店会员列表'
      }
    }]
  },
  // 车辆管理
  {
    path: '/car',
    name: '/car',
    component: Layout,
    alwaysShow: true,
    redirect: 'shop',
    meta: {
      title: '车辆管理',
      icon: 'car3'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/carList',
      meta: {
        title: '车辆列表'
      }
    }]
  },
  // 门店商品管理
  {
    path: '/goods',
    name: '/goods',
    component: Layout,
    alwaysShow: true,
    redirect: 'goods',
    meta: {
      title: '门店商品管理',
      icon: 'mdsp'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/goodsList',
      meta: {
        title: '门店商品列表'
      }
    },
    {
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/goodsTypeList',
      meta: {
        title: '门店商品类别列表'
      }
    }
    ]
  },
  // 门店订单管理
  {
    path: '/carOrder',
    name: '/carOrder',
    component: Layout,
    alwaysShow: true,
    redirect: 'carOrder',
    meta: {
      title: '门店订单管理',
      icon: 'mddd'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/carOrderList',
      meta: {
        title: '门店订单列表'
      }
    }]
  },
  // 积分商品管理
  {
    path: '/integral',
    name: '/integral',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '积分管理',
      icon: 'shangpin'
    },
    children: [{
      path: 'integralgoods',
      component: () => import('@/views/integral/integralgoods'),
      name: '/v1/integralgoods',
      meta: {
        title: '积分商品'
      }
    },
    {
      path: 'integralorder',
      component: () => import('@/views/integral/integralorder'),
      name: '/v1/integralorder',
      meta: {
        title: '积分订单'
      }
    },
    {
      path: 'setintegral',
      component: () => import('@/views/integral/setintegral'),
      name: '/v1/setintegral',
      meta: {
        title: '积分设置'
      }
    },
    {
      path: 'integral_details',
      component: () => import('@/views/integral/integral_details'),
      name: '/v1/integral_details',
      meta: {
        title: '查看订单'
      },
      hidden: true
    },
    {
      path: 'integral_editor',
      component: () => import('@/views/integral/integral_editor'),
      name: '/v1/integral_editor',
      meta: {
        title: '修改订单'
      },
      hidden: true
    },
    {
      path: 'integralgoods_add',
      component: () => import('@/views/integral/integralgoods_add'),
      name: '/v1/integralgoods_add',
      meta: {
        title: '添加商品'
      },
      hidden: true
    }
    ]
  },
  // 活动管理
  {
    path: '/activity',
    name: '/activity',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '活动管理',
      icon: 'huiyuan'
    },
    children: [{
      path: 'snapup',
      component: () => import('@/views/activity/snapup'),
      name: '/v1/snapup',
      meta: {
        title: '抢购管理'
      }
    },
    {
      path: 'luckydraw',
      component: () => import('@/views/activity/luckydraw'),
      name: '/v1/luckydraw',
      meta: {
        title: '抽奖管理'
      }
    },
    {
      path: 'addluckydraw',
      component: () => import('@/views/activity/addluckydraw'),
      name: '/v1/addluckydraw',
      meta: {
        title: '新建抽奖活动'
      },
      hidden: true
    },
    {
      path: 'addsnapup',
      component: () => import('@/views/activity/addsnapup'),
      name: '/v1/addsnapup',
      meta: {
        title: '新建抢购活动'
      },
      hidden: true
    }
    ]
  },
  // 客户管理
  {
    path: '/member',
    name: '/member',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '客户',
      icon: 'huiyuan'
    },
    children: [{
      path: 'memberlist',
      component: () => import('@/views/member1/memberlist'),
      name: '/v1/memberlist',
      meta: {
        title: '客户列表'
      }
    },
    {
      path: 'membercat',
      component: () => import('@/views/member1/memberlistcat'),
      name: '/v1/membercar',
      meta: {
        title: '客户车辆'
      },
      hidden: true
    },
    {
      path: 'vippage',
      component: () => import('@/views/member1/vipPage'),
      name: '/v1/vippage',
      meta: {
        title: '客户会员卡详情'
      },
      hidden: true
    },
    {
      path: 'membermessagecat',
      component: () => import('@/views/member1/membermessagecat'),
      name: '/v1/membermessagecat',
      meta: {
        title: '车辆字段'
      },
      hidden: true
    },
    {
      path: 'membercard',
      component: () => import('@/views/member1/memberviplist'),
      name: '/v1/membercard',
      meta: {
        title: '会员卡列表'
      }
    }
    ]
  },
  // 平台直采
  {
    path: '/platformPurchase',
    name: '/platformPurchase',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '采购',
      icon: 'shangpin'
    },
    children: [{
      path: 'shoporderlist',
      component: () => import('@/views/purchase/shoporderlist'),
      name: '/v1/shoporderlist',
      meta: {
        title: '平台直采'
      }
    },
    {
      path: 'editororder',
      component: () => import('@/views/purchase/editor_order'),
      name: '/v1/editororder',
      meta: {
        title: '修改订单'
      },
      hidden: true
    },
    {
      path: 'shoporderdetails',
      component: () => import('@/views/purchase/shoporder_details'),
      name: '/v1/shoporderdetails',
      meta: {
        title: '订单信息'
      },
      hidden: true
    },
    {
      path: 'commoditylist',
      component: () => import('@/views/purchase/commoditylist'),
      name: '/v1/commoditylist',
      meta: {
        title: '开新订单'
      },
      hidden: true
    },
    {
      path: 'billing',
      component: () => import('@/views/purchase/billing'),
      name: '/v1/billing',
      meta: {
        title: '开单'
      }
    }
    ]
  },
  // 订单管理
  {
    path: '/order',
    name: '/order',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    meta: {
      title: '订单管理',
      icon: 'dingdan'
    },
    children: [{
      path: 'orderlist',
      component: () => import('@/views/order/orderlist'),
      name: '/v1/orderlist',
      meta: {
        title: '订单列表'
      }
    },
    {
      path: 'editor_order',
      component: () => import('@/views/order/editor_order'),
      name: '/v1/editor_order',
      meta: {
        title: '修改订单'
      },
      hidden: true
    },
    {
      path: 'order_details',
      component: () => import('@/views/order/order_details'),
      name: '/v1/order_details',
      meta: {
        title: '订单信息'
      },
      hidden: true
    }
    ]
  },
  // 商家管理
  {
    path: '/merchant',
    name: '/merchant',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    redirect: '/v1/merchant',
    meta: {
      title: '商家管理',
      icon: 'shangjia'
    },
    children: [
      {
        path: 'shop',
        component: () => import('@/views/merchant/shop'),
        name: '/v1/shop',
        meta: {
          title: '门店管理'
        }
      },
      /* {
       path: 'merchant',
       component: () => import('@/views/merchant/merchant'),
       name: '/v1/merchant',
       meta: {
         title: '商家管理'
       }
     },*/
      {
        path: 'bannerstore',
        component: () => import('@/views/merchant/bannerstore'),
        name: '/v1/bannerstore',
        meta: {
          title: '店铺banner'
        },
        hidden: true
      },
      /* {
        path: 'merchantlist',
        component: () => import('@/views/merchant/merchantlist'),
        name: '/v1/merchantlist',
        meta: {
          title: '审核店铺'
        }
      },*/
      {
        path: 'merchant_add',
        component: () => import('@/views/merchant/merchant_add'),
        name: '/v1/merchant_add',
        meta: {
          title: '新增店铺'
        },
        hidden: true
      }
    ]
  },
  // 图片管理
  {
    path: '/picture',
    name: '/picture',
    component: Layout,
    alwaysShow: true,
    redirect: 'iconList',
    meta: {
      title: '图片管理',
      icon: 'picture'
    },
    children: [{
      path: 'iconList',
      component: () => import('@/views/picture/iconList'),
      name: '/v1/iconList',
      meta: {
        title: '图片列表'
      }
    }]
  },
  // 视频管理
  {
    path: '/video',
    name: '/video',
    component: Layout,
    alwaysShow: true,
    redirect: 'noredirect',
    meta: {
      title: '视频管理',
      icon: 'video'
    },
    children: [{
      path: 'videoList',
      component: () => import('@/views/video/videoList'),
      name: '/v1/videoList',
      meta: {
        title: '视频列表'
      }
    },
    {
      path: 'videoType',
      component: () => import('@/views/video/videoType'),
      name: '/v1/videoType',
      meta: {
        title: '视频分类'
      }
    },
    {
      path: 'comment/:data',
      component: () => import('@/views/video/comment'),
      name: '/v1/comment',
      meta: {
        title: '评论管理'
      },
      hidden: true
    },
    {
      path: 'commentsecond/:commentId',
      component: () => import('@/views/video/commentsecond'),
      name: '/v1/commentsecond',
      meta: {
        title: '二级评论管理'
      },
      hidden: true
    }
    ]
  },
  // 资讯管理
  {
    path: '/information',
    name: '/information',
    component: Layout,
    alwaysShow: true,
    redirect: 'noredirect',
    meta: {
      title: '资讯管理',
      icon: 'information'
    },
    children: [{
      path: 'information',
      component: () => import('@/views/information/information'),
      name: '/v1/information',
      meta: {
        title: '资讯列表'
      }
    },
    {
      path: 'informationtype',
      component: () => import('@/views/information/informationtype'),
      name: '/v1/informationtype',
      meta: {
        title: '分类管理'
      }
    },
    {
      path: 'comment/:id',
      component: () => import('@/views/information/comment'),
      name: '/v1/comment1',
      meta: {
        title: '评论管理'
      },
      hidden: true
    }
    ]
  },
  // 钓场管理
  /* {
    path: '/fishing',
    name: '/fishing',
    component: Layout,
    alwaysShow: true,
    redirect: 'fishing',
    meta: {
      title: '钓场管理',
      icon: 'information'
    },
    children: [{
      path: 'fishing',
      component: () => import('@/views/fishing/fishing'),
      name: '/v1/fishing',
      meta: {
        title: '钓场列表'
      }
    }, {
      path: 'fishone/:id',
      component: () => import('@/views/fishing/fishone'),
      name: '/v1/fishone',
      meta: {
        title: '评论管理'
      },
      hidden: true
    }, {
      path: 'fishtwo/:id',
      component: () => import('@/views/fishing/fishtwo'),
      name: '/v1/fishtwo',
      meta: {
        title: '评论管理'
      },
      hidden: true
    }]
  },*/
  // 敏感词管理
  {
    path: '/sensitive',
    name: '/sensitive',
    component: Layout,
    alwaysShow: true,
    redirect: 'sensitive',
    meta: {
      title: '敏感词管理',
      icon: 'sensitive'
    },
    children: [{
      path: 'sensitive',
      component: () => import('@/views/sensitive/sensitive'),
      name: '/v1/sensitive',
      meta: {
        title: '敏感词管理列表'
      }
    }]
  },
  // 信息管理模块
  {
    path: '/message',
    name: '/message',
    component: Layout,
    alwaysShow: true,
    redirect: 'message',
    meta: {
      title: '信息管理',
      icon: 'message'
    },
    children: [{
      path: 'message',
      component: () => import('@/views/message/message'),
      name: '/v1/message',
      meta: {
        title: '信息列表'
      }
    },
    {
      path: 'editmessage',
      component: () => import('@/views/message/editmessage'),
      name: '/v1/editmessage',
      meta: {
        title: '编辑信息'
      },
      hidden: true
    }
    ]
  },
  // 公告管理
  {
    path: '/announcement',
    name: '/announcement',
    component: Layout,
    alwaysShow: true,
    redirect: 'announcement',
    meta: {
      title: '公告管理',
      icon: 'announcement'
    },
    children: [{
      path: 'announcement',
      component: () => import('@/views/announcement/announcement'),
      name: '/v1/announcement',
      meta: {
        title: '公告列表'
      }
    }]
  },
  // 评论管理
  {
    path: '/comment',
    name: '/comment',
    component: Layout,
    alwaysShow: true,
    redirect: 'comment',
    meta: {
      title: '评论管理',
      icon: 'comment'
    },
    children: [{
      path: 'comment',
      component: () => import('@/views/comment/comment'),
      name: '/v1/comment',
      meta: {
        title: '评论列表'
      }
    }]
  },

  // 粉丝管理
  {
    path: '/fans',
    name: '/fans',
    component: Layout,
    alwaysShow: true,
    redirect: 'fans',
    meta: {
      title: '粉丝管理',
      icon: 'fans'
    },
    children: [{
      path: 'fans',
      component: () => import('@/views/fans/fans'),
      name: '/v1/fans',
      meta: {
        title: '粉丝列表'
      }
    }]
  },

  // 活动公告
  {
    path: '/activitynotice',
    name: '/activitynotice',
    component: Layout,
    alwaysShow: true,
    redirect: 'activitynotice',
    meta: {
      title: '活动公告',
      icon: 'announcement'
    },
    children: [{
      path: 'activitynotice',
      component: () => import('@/views/activitynotice/activitynotice'),
      name: '/v1/activitynotice',
      meta: {
        title: '公告列表'
      }
    }]
  },


  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]
